Developer Documentation

QuickTime 4 API Documentation

Inside Macintosh: QuickTime Components

Previous | Overview | Contents | Next |

Controlling Sequence Grabber Components

Sequence grabber components provide a full set of functions that allow your application to control the preview or record operation. You can use these functions to start and stop the operation, to pause data collection, and to retrieve a reference to the movie that is created during a record operation. This section describes these functions.

Use the SGStartPreview function to start a preview operation. The SGStartRecord function lets you start a record operation. The SGStop function allows you to stop a sequence grabber component.

You can instruct the sequence grabber to pause by calling the SGPause function. You can determine whether the sequence grabber is paused by calling the SGGetPause function.

You grant processing time to the sequence grabber by calling the SGIdle function. Be sure to call this function often during record and preview operations. If your application receives an update event during a record or preview operation, you should call the SGUpdate function.

You can prepare the sequence grabber for an upcoming preview or record operation by calling the SGPrepare function. This function also allows the sequence grabber to verify that it can support the parameters you have specified. By verifying the parameters you want to use, you can improve the startup of preview and record operations. Use the SGRelease function to release system resources after calling the SGPrepare function.

You can retrieve a reference to the movie created by a record operation by calling the SGGetMovie function. You can determine the resource ID value assigned to the last movie resource created by the sequence grabber by calling the SGGetLastMovieResID function.

You can extract a picture from the video source data by calling the SGGrabPict function.

SGStartPreview

The SGStartPreview function instructs the sequence grabber to begin processing data from its channels.

pascal ComponentResult SGStartPreview (SeqGrabComponent s);
s
Specifies the component instance that identifies your connection to the sequence grabber component. You obtain this value from the Component Manager's OpenDefaultComponent or OpenComponent function.

DESCRIPTION

The sequence grabber immediately presents the data to the user in the appropriate format, according to the channel configuration parameters you have specified (see "Working With Channel Characteristics," for information about configuring channels). Video data is displayed in the destination display region; sound data is played at the specified volume settings.

RESULT CODES

cantDoThatInCurrentMode

-9402

Request invalid in current mode

deviceCantMeetRequest

-9408

Device cannot support grabber

File Manager errors Memory Manager errors

SEE ALSO

You stop the preview process by calling the SGStop function, which is described on SGStop .

In preview mode, the sequence grabber does not save any of the data it gathers from its channels. If you want to record the data, use record mode. You start a record operation by calling the SGStartRecord function, which is described in the next section.

SGStartRecord

The SGStartRecord function instructs the sequence grabber component to begin collecting data from its channels.

pascal ComponentResult SGStartRecord (SeqGrabComponent s);
s
Specifies the component instance that identifies your connection to the sequence grabber component. You obtain this value from the Component Manager's OpenDefaultComponent or OpenComponent function.

DESCRIPTION

The sequence grabber stores the collected data according to the recording parameters you specify with the SGSetDataOutput function, which is described on SGSetDataOutput . Before calling this function, you must correctly configure the sequence grabber's channels--see "Working With Channel Characteristics," for information about configuring sequence grabber channels.

RESULT CODES

cantDoThatInCurrentMode

-9402

Request invalid in current mode

notEnoughMemoryToGrab

-9403

Insufficient memory for record operation

notEnoughDiskSpaceToGrab

-9404

Insufficient disk space for record operation

deviceCantMeetRequest

-9408

Device cannot support grabber

File Manager errors Memory Manager errors

SEE ALSO

You can switch from previewing to recording by calling this function during a preview operation--you need not stop the preview operation first. You stop the recording process by calling the SGStop function, which is described on SGStop .

You can cause the sequence grabber to display the data it obtains from its channels without storing any of the data by calling the SGStartPreview function, which is described in the previous section.

SGIdle

The SGIdle function provides processing time to the sequence grabber component and its channel components. After starting a preview or record operation, you should call this function as often as possible, until you stop the operation by calling SGStop .

Warning
If you do not call SGIdle frequently enough, you may lose data.

pascal ComponentResult SGIdle (SeqGrabComponent s);
s
Specifies the component instance that identifies your connection to the sequence grabber component. You obtain this value from the Component Manager's OpenDefaultComponent or OpenComponent function.

DESCRIPTION

The SGIdle function reports several status and error conditions by means of its result code. If you have established a time limit for a record operation by calling the SGSetMaximumRecordTime function (described on SGSetMaximumRecordTime ), SGIdle returns a result code of grabTimeComplete when the time limit expires. In addition, SGIdle reports errors that are specific to the channels that are active for a given operation. If SGIdle returns a nonzero result code during a record operation, you should still call the SGStop function (described on SGStop ) so that the sequence grabber can store the data it has collected.

RESULT CODES

grabTimeComplete

-9401

Time for record operation has expired

cantDoThatInCurrentMode

-9402

Request invalid in current mode

File Manager errors Memory Manager errors

SGUpdate

The SGUpdate function allows you to tell the sequence grabber that it must refresh its display.

pascal ComponentResult SGUpdate (SeqGrabComponent s,
                                          RgnHandle updateRgn);
s
Specifies the component instance that identifies your connection to the sequence grabber component. You obtain this value from the Component Manager's OpenDefaultComponent or OpenComponent function.

updateRgn
Indicates the part of the window that has been changed. You may use this parameter to specify a portion of the window that you know has been changed. You can obtain this information by examining the appropriate window record. For example:

    SGUpdate (theSG, ((WindowPeek)updateWindow)->updateRgn);
If you set this parameter to nil , the sequence grabber uses the window's current visible region.

DESCRIPTION

You may use the SGUpdate function to tell the sequence grabber that it must refresh its display. You should call this function whenever you receive an update event for a window that contains a sequence grabber display. You should call this function before calling the Window Manager's BeginUpdate function.

Your application should avoid drawing where the sequence grabber is displaying video. Doing so may cause some video digitizer components to stop displaying video.

SPECIAL CONSIDERATIONS

It is dangerous to allow an update event to occur during recording. Many digitizers capture directly to the screen; thus, an update event will result in data loss.

RESULT CODES

paramErr

-50

Component not found

deviceCantMeetRequest

-9408

Device cannot support grabber

SGStop

The SGStop function stops a preview or record operation.

pascal ComponentResult SGStop (SeqGrabComponent s);
s
Specifies the component instance that identifies your connection to the sequence grabber component. You obtain this value from the Component Manager's OpenDefaultComponent or OpenComponent function.

DESCRIPTION

The sequence grabber releases any system resources it used during the operation, such as temporary memory. In the case of a record operation, the sequence grabber stores the collected movie data in the assigned movie file--you specify the movie file by calling the SGSetDataOutput function, which is described on SGSetDataOutput .

RESULT CODES

cantDoThatInCurrentMode

-9402

Request invalid in current mode

File Manager errors Memory Manager errors

SGPause

You can suspend or restart a record or preview operation by calling the SGPause function. You supply a byte value that instructs the sequence grabber whether to pause or restart the current operation.

pascal ComponentResult SGPause (SeqGrabComponent s,
                                          Byte pause);
s
Specifies the component instance that identifies your connection to the sequence grabber component. You obtain this value from the Component Manager's OpenDefaultComponent or OpenComponent function.

pause
Instructs the sequence grabber whether to suspend or restart the current operation. The following values are valid:

seqGrabUnpause
Restarts the current operation.

seqGrabPause
Pauses the current operation.

seqGrabPauseForMenu
Pauses the current operation so that you may display a menu. Use this option only in preview mode, just before you call the Menu Manager's MenuSelect or PopUpMenuSelect function. In this case, the sequence grabber may not pause all channels, depending upon the ability of the sequence grabber to play with acceptable quality. For example, sound channels may continue to play while video channels are paused.

DESCRIPTION

The SGPause function does not release any system resources or temporary memory associated with the current operation. Consequently, it is generally much faster than using the SGStop and SGStartRecord functions or the SGStartPreview function to suspend an operation.

SPECIAL CONSIDERATIONS

When you restart the operation, the sequence grabber component may be unable to satisfy your request. This can occur, for example, if the user has moved the display window to a location that the digitizing hardware cannot support.

RESULT CODES

cantDoThatInCurrentMode

-9402

Request invalid in current mode

notEnoughMemoryToGrab

-9403

Insufficient memory for record operation

deviceCantMeetRequest

-9408

Device cannot support grabber

File Manager errors Memory Manager errors

SEE ALSO

You may determine whether the sequence grabber is paused by calling the SGGetPause function, which is described next.

SGGetPause

You can determine whether the sequence grabber is paused by calling the SGGetPause function.

pascal ComponentResult SGGetPause (SeqGrabComponent s,
                                          Byte *paused);
s
Specifies the component instance that identifies your connection to the sequence grabber component. You obtain this value from the Component Manager's OpenDefaultComponent or OpenComponent function.

paused
Contains a pointer to a field that is to receive a value that indicates whether the sequence grabber is currently paused. The following values are valid:

seqGrabUnpause
The sequence grabber is not paused.

seqGrabPause
The sequence grabber is paused--all channels are stopped.

seqGrabPauseForMenu
The sequence grabber is paused in order to display a menu--some or all of the channels may be stopped.

DESCRIPTION

The SGGetPause function allows you to determine whether the sequence grabber is paused.

SEE ALSO

You may pause or restart the sequence grabber by calling the SGPause function, which is described in the previous section.

SGPrepare

The SGPrepare function instructs the sequence grabber to get ready to begin a preview or record operation (or to commence both operations). You specify the operations.

pascal ComponentResult SGPrepare (SeqGrabComponent s,
                                         Boolean prepareForPreview,
                                         Boolean prepareForRecord);
s
Specifies the component instance that identifies your connection to the sequence grabber component. You obtain this value from the Component Manager's OpenDefaultComponent or OpenComponent function.

prepareForPreview
Instructs the sequence grabber component to prepare for a preview operation. Set this parameter to true to prepare for a preview operation. You may set both the prepareForPreview and prepareForRecord parameters to true .

prepareForRecord
Instructs the sequence grabber component to prepare for a record operation. Set this parameter to true to prepare for a record operation. You may set both the prepareForPreview and prepareForRecord parameters to true .

DESCRIPTION

The sequence grabber component does whatever is necessary to get ready to start the preview or record operation. This may involve allocating memory, readying hardware, and notifying the sequence grabber's channels. By calling this function, you ensure that the SGStartRecord or SGStartPreview function starts as quickly as possible.

If you do not call this function before starting a record or preview operation, the sequence grabber component makes these preparations when you start the operation. You cannot call this function after you start a preview or record operation.

If you call SGPrepare without subsequently starting a record or preview operation, you should call the SGRelease function (described in the next section). This allows the sequence grabber component to release any system resources it allocated when you called SGPrepare .

SPECIAL CONSIDERATIONS

The window in which the sequence grabber is to draw video frames (as defined by the SGSetGWorld function, described on SGSetGWorld ) must be visible before you call the SGPrepare function. Otherwise, the sequence grabber does not display the frames properly. If the window isn't visible and SGPrepare is called with the prepareForPreview parameter set to true and the prepareForRecord parameter set to false , and the window is subsequently shown via the Window Manager's ShowWindow routine, the sequence grabber won't display frames properly in the video window. The visible region of the window wasn't valid when the SGPrepare call was made.

RESULT CODES

paramErr

-50

Invalid parameter specified

cantDoThatInCurrentMode

-9402

Request invalid in current mode

notEnoughMemoryToGrab

-9403

Insufficient memory for record operation

notEnoughDiskSpaceToGrab

-9404

Insufficient disk space for record operation

deviceCantMeetRequest

-9408

Device cannot support grabber

File Manager errors Memory Manager errors

SGRelease

The SGRelease function instructs the sequence grabber to release any system resources it allocated when you called the SGPrepare function, which is described in the previous section. You should call SGRelease whenever you call SGPrepare without subsequently starting a record or preview operation.

pascal ComponentResult SGRelease (SeqGrabComponent s);
s
Specifies the component instance that identifies your connection to the sequence grabber component. You obtain this value from the Component Manager's OpenDefaultComponent or OpenComponent function.

DESCRIPTION

When you stop a record or preview operation by calling the SGStop function, the sequence grabber component automatically releases the resources it uses during the operation. Consequently, you do not have to call this function after a record or preview operation.

You cannot call the SGRelease function during a record or preview operation.

SGGetMovie

The SGGetMovie function returns a reference to the movie that contains the data collected during a record operation. You can use this movie identifier with Movie Toolbox functions. However, you should not dispose of this movie--it is owned by the sequence grabber component. Furthermore, the sequence grabber component disposes of this movie when you prepare for or start the next record or preview operation, or when you close the connection to the sequence grabber. If you want to work with a movie containing the collected data, use the Movie Toolbox's NewMovieFromFile function (see the chapter "Movie Toolbox" in Inside Macintosh: QuickTime for more information).

You can call this function only after you have stopped the record operation by calling the SGStop function.

pascal Movie SGGetMovie (SeqGrabComponent s);
s
Specifies the component instance that identifies your connection to the sequence grabber component. You obtain this value from the Component Manager's OpenDefaultComponent or OpenComponent function.

DESCRIPTION

The SGGetMovie function returns a reference to the movie that contains the data collected during a record operation. If there is no current movie, either because you are in preview mode or because you have not yet stopped the record operation, the sequence grabber component sets this returned reference to nil .

RESULT CODE

seqGrabInfoNotAvailable

-9407

Sequence grabber cannot support request

SGGetLastMovieResID

The SGGetLastMovieResID allows you to retrieve the last resource ID used by the sequence grabber component. The sequence grabber component assigns a new resource ID to each movie resource it creates. The sequence grabber creates the movie resource when you stop a record operation by calling the SGStop function, unless you have instructed the sequence grabber not to add the movie resource to the movie file (see the description of the SGSetDataOutput function beginning on SGSetDataOutput for more information).

pascal ComponentResult SGGetLastMovieResID (SeqGrabComponent s,
                                          short *resID) ;
s
Specifies the component instance that identifies your connection to the sequence grabber component. You obtain this value from the Component Manager's OpenDefaultComponent or OpenComponent function.

resID
Contains a pointer to an integer that is to receive the resource ID the sequence grabber assigned to the movie resource it just created.

DESCRIPTION

If you want this information, you should call this function before you prepare for or start another record or preview operation--because the sequence grabber component resets this value when you start the next operation.

RESULT CODE

seqGrabInfoNotAvailable

-9407

Sequence grabber cannot support request

SGGrabPict

The SGGrabPict function provides a simple interface that allows your application to obtain a QuickDraw picture from a sequence grabber component. The sequence grabber can display the picture directly, or it can write the picture to an offscreen buffer. This function is limited in scope, however, and does not allow you to control all of the parameters that govern the operation. When you call this function, the sequence grabber component obtains and configures appropriate sequence grabber channel components (if necessary), grabs the data, and then releases any components it obtained.

pascal ComponentResult SGGrabPict (SeqGrabComponent s,
                                         PicHandle *p,
                                         const Rect *bounds,
                                         short offscreenDepth,
                                         long grabPictFlags);
s
Specifies the component instance that identifies your connection to the sequence grabber component. You obtain this value from the Component Manager's OpenDefaultComponent or OpenComponent function.

p
Contains a pointer to a field that is to receive a handle to the picture. If the SGGrabPict function cannot create the picture, it sets this handle to nil .

bounds
Contains a pointer to the boundary region for the picture. By default, this rectangle lies in the current graphics port. If you set the grabPictOffScreen flag in the grabPictFlags parameter to 1, the sequence grabber places the picture in an offscreen graphics world. In this case, the rectangle is interpreted in that offscreen world.

offscreenDepth
Specifies the pixel depth for the offscreen graphics world. This parameter is typically set to 0, which chooses the best available depth. If you set the grabPictOffScreen flag in the grabPictFlags parameter to 1, the sequence grabber places the picture in an offscreen graphics world. You specify the pixel depth of this offscreen graphics world with this parameter. If you are displaying the picture, this parameter is ignored.

grabPictFlags
Contains flags that control the operation. The following flags are defined (set unused flags to 0):

grabPictOffScreen
Instructs the sequence grabber to place the picture in an offscreen graphics world. Set this flag to 1 to use an offscreen graphics world. In this case, you use the offscreenDepth parameter to specify the pixel depth in the offscreen buffer. In addition, the rectangle specified by the bounds parameter is applied to the offscreen buffer.

grabPictIgnoreClip
Instructs the sequence grabber to ignore any clipping regions you may have defined for the sequence grabber's channels. Set this flag to 1 to have the sequence grabber ignore these clipping regions.

DESCRIPTION

If you have created any channels for the sequence grabber component, the SGGrabPict function uses those channels to obtain the data for the captured image.

SPECIAL CONSIDERATIONS

Some digitizer sources do not support grabbing offscreen, so the SGGrabPict function may fail. In this case, try again grabbing onscreen.

RESULT CODES

notEnoughMemoryToGrab

-9403

Insufficient memory for record operation

deviceCantMeetRequest

-9408

Device cannot support grabber

badDepthErr

-2207

Can't digitize into this depth

File Manager errors Memory Manager errors


© 1999 Apple Computer, Inc.

Previous | Overview | Contents | Next